package org.dromara.system.controller.device;

import java.util.List;

import lombok.RequiredArgsConstructor;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.dromara.system.domain.vo.DeviceCollectListVo;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import org.dromara.common.idempotent.annotation.RepeatSubmit;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.web.core.BaseController;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.core.domain.R;
import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.core.validate.EditGroup;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.excel.utils.ExcelUtil;
import org.dromara.system.domain.vo.DeviceCollectVo;
import org.dromara.system.domain.bo.DeviceCollectBo;
import org.dromara.system.service.IDeviceCollectService;
import org.dromara.common.mybatis.core.page.TableDataInfo;

/**
 * 设备收藏
 *
 * @author Lion Li
 * @date 2024-10-21
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/system")
public class DeviceCollectController extends BaseController {

    private final IDeviceCollectService deviceCollectService;

    /**
     * 查询设备收藏列表
     */

//    @GetMapping("/collect/list")
//    public TableDataInfo<DeviceCollectListVo> list(DeviceCollectBo bo, PageQuery pageQuery) {
//        return deviceCollectService.queryPageList(bo, pageQuery);
//    }

    /**
     * 设备收藏
     */

    @Log(title = "设备批量收藏", businessType = BusinessType.OTHER)
    @RepeatSubmit()
    @PostMapping("/batchCollect")
    public R<Void> batchCollect(@Validated(AddGroup.class) @RequestBody DeviceCollectBo bo) {
        return toAjax(deviceCollectService.deviceCollect(List.of(bo.getDeviceIds())));
    }

    @Log(title = "设备单独收藏", businessType = BusinessType.OTHER)
    @RepeatSubmit()
    @PostMapping("/collect/{id}")
    public R<Void> collect(@PathVariable Long id) {
        return toAjax(deviceCollectService.deviceCollectById(id));
    }


}
